package com.scpii.universal.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.scpii.universal.hibernate.dao.BaseDao;
import com.scpii.universal.hibernate.entity.PageModuleConTab;
import com.scpii.universal.hibernate.intface.BaseInterface;

public class PageModuleConTabService implements BaseInterface<PageModuleConTab> {
	
	private BaseDao<PageModuleConTab> pageModuleConTabDao;
	private static final String GET_DISPLAY_MODULES = "select * from page_module_con_tab " +
			"where int_delete_sign=0 and int_page_detail_id=" +
			"(select int_page_detail_id from app_detail_page_tab where int_delete_sign=0 and int_detail_page_cateid=:int_detail_page_cateid and int_app_id=:int_app_id) " +
			"order by int_page_module_order asc";

	public void setPageModuleConTabDao(BaseDao<PageModuleConTab> pageModuleConTabDao) {
		this.pageModuleConTabDao = pageModuleConTabDao;
	}

	@Override
	public PageModuleConTab get(Integer id) throws Exception {
		return null;
	}

	@Override
	public List<PageModuleConTab> getAll() throws Exception {
		return null;
	}

	@Override
	public PageModuleConTab get(String propertyName, Object value)
			throws Exception {
		return null;
	}

	@Override
	public List<PageModuleConTab> getList(String propertyName, Object value)
			throws Exception {
		return null;
	}

	@Override
	public Long getTotalCount() throws Exception {
		return null;
	}

	@Override
	public void save(PageModuleConTab obj) throws Exception {
		
	}

	@Override
	public void update(PageModuleConTab obj) throws Exception {
		
	}

	@Override
	public void delete(PageModuleConTab obj) throws Exception {
		
	}

	@Override
	public void delete(Integer id) throws Exception {
		
	}

	@Override
	public List<PageModuleConTab> hqlGetList(String hql,
			Map<String, Object> argsMap) throws Exception {
		return null;
	}

	@Override
	public void hqlUpdate(String namedHqlQuery, Map<String, Object> argsMap)
			throws Exception {
		
	}

	@Override
	public Long hqlGetNums(String namedHqlQuery, Map<String, Object> argsMap)
			throws Exception {
		return null;
	}

	@Override
	public List<PageModuleConTab> sqlGetList(String sqls,
			Map<String, Object> argsMap) throws Exception {
		return pageModuleConTabDao.sqlGetList(sqls, argsMap);
	}

	@Override
	public void sqlUpdate(String sqls, Map<String, Object> argsMap)
			throws Exception {
		
	}

	@Override
	public Long sqlGetNum(String sqls, Map<String, Object> argsMap)
			throws Exception {
		return null;
	}
	
	public String getDisplayModules(int cateId,int appId) throws Exception {
		String modules = "1,3,5,6";//default
		if(cateId <= 0) {
			return modules;
		}
		Map<String, Object> argsMap = new HashMap<String, Object>();
		argsMap.put("int_detail_page_cateid", cateId);
		argsMap.put("int_app_id", appId);
		List<PageModuleConTab> result = pageModuleConTabDao.sqlGetList(GET_DISPLAY_MODULES, argsMap);
		StringBuffer sbuf = new StringBuffer();
		if (result != null && result.size() > 0) {
			for (PageModuleConTab pageModuleConTab : result) {
				sbuf.append(pageModuleConTab.getIntPageModuleId());
				sbuf.append(",");
			}
			sbuf.deleteCharAt(sbuf.lastIndexOf(","));
			modules = sbuf.toString();
		}
		return modules;
	}

}
